GBML manual / Collision

attack_touching

True if one of this object’s attack boxes, on the frame it is showing now, touches a body box of an instance of obj. A frame with no body box uses the object’s collision box as its body. Name more objects after the first and it is true if it touches any of them.

Works differently on Game Boy - Animations play as on the Advance, with smaller limits: a frame lasts up to 650 sixtieths of a second, a frame has at most 4 boxes of each kind, and a game has up to 255 animations.

Works differently on Game Boy Color - Animations play as on the Advance, with smaller limits: a frame lasts up to 650 sixtieths of a second, a frame has at most 4 boxes of each kind, and a game has up to 255 animations.

On other consoles this differs: see Side by side and How the consoles differ.

Syntax

attack_touching(obj, ...more) -> bool

Arguments

NameType
objobject
...moreobject (any number of them, none included)

Returns

bool

Description

True if one of this object's attack boxes, on the frame it is showing now, touches a body box of an instance of obj. A frame with no body box uses the object's collision box as its body. Name more objects after the first and it is true if it touches any of them. Each object named counts together with its children.

It only asks. It remembers nothing, so it is true on every frame the boxes touch. To react once per swing use the Attack hits event.

Boxes flip with the picture: a negative xscale or flip_x mirrors them left to right.

Example

if (attack_touching(obj_enemy)) {
    hsp = 0;
}

Stops moving while the swing is touching an enemy.

On the GBA

This only asks; it remembers nothing, so it is true on every frame the boxes touch. For "hit it once per swing" use the Attack hits event instead. Boxes flip with the picture (a negative xscale or flip_x mirrors them). Each object named is checked together with its children, like pos_meeting.

See also: Animationsattack_hitspos_meetingcollides